﻿using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Artech.Core
{
    internal class DefaultServiceLocatorTypeRegistrationsProvider : ITypeRegistrationsProvider
    {
        public IEnumerable<TypeRegistration> GetRegistrations(IConfigurationSource configurationSource)
        {
            Expression<Func<IServiceLocator>> newExpression = () => new UnityServiceLocator(configurationSource);
            TypeRegistration serviceLocatorRegistration = new TypeRegistration<IServiceLocator>(newExpression)
            {
                Name = Guid.NewGuid().ToString(),
                IsPublicName = true,
                IsDefault = true
            };
            return new TypeRegistration[] { serviceLocatorRegistration };
        }

        public IEnumerable<TypeRegistration> GetUpdatedRegistrations(IConfigurationSource configurationSource)
        {
            return this.GetRegistrations(configurationSource);
        }
    }
}
